package com.hyz.login.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyz.login.model.Register;
import com.hyz.login.mapper.RegisterMapper;
import com.hyz.login.model.Report;
import com.hyz.login.service.RegisterService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zwq
 * @since 2022-11-28
 */
@Service
public class RegisterServiceImpl
        extends ServiceImpl<RegisterMapper, Register> implements RegisterService {
    @Autowired
    private RegisterMapper registerMapper;

    @Override
    public IPage<Register> adminFindPage(String userNam, Integer page, Integer limit) {
        QueryWrapper<Register> wrapper = new QueryWrapper<Register>();
        wrapper.like("userName",userNam);
        wrapper.like("state",0);
        IPage<Register> iPage = new Page<Register>();
        iPage.setRecords(registerMapper.findAll(userNam, page-1, limit));
        iPage.setTotal(registerMapper.selectCount(wrapper));
        iPage.setCurrent(page);
        iPage.setSize(limit);
        return iPage;
    }

    @Override
    public Integer modifyByRegId(Integer registerid, Integer departmentId, Integer doctorId, Integer bedId) {
        return registerMapper.modifyByRegId(registerid, departmentId, doctorId, bedId);
    }

    @Override
    public Integer addRegister(Register register) {
        register.setState(0);
        return registerMapper.insert(register);
    }

    @Override
    public Register findById(Integer registerid) {
        return registerMapper.findById(registerid);
    }

    @Override
    public Integer modifyMoney(Integer registerid, Integer moneys) {
        return registerMapper.modifyMoney(registerid, moneys);
    }

}
